home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #11 / Amiga Plus CD - 2004 - No. 11.iso / AmiSoft / Dev / misc / temgen.lha / Temgen / tg-0.11 / use.c < prev    next >
C/C++ Source or Header  |  2002-12-18  |  675b  |  38 lines

  1. #include "generator.h"
  2. #include "lintab.h"
  3. #include "use.h"
  4.  
  5. static struct lintab *used_files = 0;
  6. static int used_iter = 0;
  7.  
  8. void do_use( int fname )
  9. {
  10.     int i, n;
  11.  
  12.     if ( !used_files ) 
  13.         used_files = new_lintab( 32, 32 );
  14.     
  15.     if ( !used_files ) fatal( "Memory allocation error in 'use'" );
  16.     
  17.     n = lt_maxindex( used_files );
  18.      
  19.     for ( i=0; i<=n; i++ ) {
  20.         int name;
  21.         
  22.         name = (int)lt_get( used_files, i );
  23.         if ( name == fname ) return;
  24.     }
  25.     
  26.     lt_set( used_files, n+1, (void*)fname );
  27. }
  28.  
  29. void reset_use( void )
  30. {
  31.     used_iter = 0;
  32. }
  33.  
  34. int  next_use( void )
  35. {
  36.     return (int)lt_get( used_files, used_iter++ );
  37. }
  38.